exports.login = async (ctx, next) => {
  const query = ctx.query
  const username = query.name
  const password = query.pwd
  if (global.username === username && global.password === password) {
    ctx.status = 200
    ctx.originData = '登录成功'
  } else {
    ctx.status = 500
    ctx.originData = '登录失败'
  }
  await next()
}

exports.register = async (ctx, next) => {
  const query = ctx.query
  const username = query.name
  const password = query.pwd
  if (username && password) {
    global.username = username
    global.password = password
    ctx.status = 200
    ctx.originData = '注册成功'
  } else {
    ctx.status = 201
    ctx.originData = '注册失败'
  }
  await next()
}
